mir: set cursor
authorWilliam Hua <william@attente.ca>
Mon, 3 Nov 2014 16:46:45 +0000 (11:46 -0500)
committerRyan Lortie <desrt@desrt.ca>
Thu, 6 Nov 2014 21:18:53 +0000 (16:18 -0500)
gdk/mir/gdkmirdisplay.c
gdk/mir/gdkmirwindowimpl.c

index d450837d5103c58376b41201ed29c168d0eb4cb1..b38cc98796d163981b95d1ba6389d0a04e4d70aa 100644 (file)
@@ -317,9 +317,7 @@ static GdkCursor *
 gdk_mir_display_get_cursor_for_type (GdkDisplay    *display,
                                      GdkCursorType  cursor_type)
 {
-  //g_printerr ("gdk_mir_display_get_cursor_for_type (%u)\n", cursor_type);
-  /* We don't support configurable cursors */
-  return g_object_ref (GDK_MIR_DISPLAY (display)->cursor);
+  return _gdk_mir_cursor_new (display, cursor_type);
 }
 
 static GdkCursor *
index 2be0ca406bb93131faec8f288ae0290fe1be7ced..e3d21eb497f57313aba237acb53d768e309d0f76 100644 (file)
@@ -552,13 +552,95 @@ gdk_mir_window_impl_reparent (GdkWindow *window,
   return FALSE;
 }
 
+static const gchar *
+get_cursor_name_for_cursor_type (GdkCursorType cursor_type)
+{
+  switch (cursor_type)
+    {
+    case GDK_BLANK_CURSOR:
+      return mir_disabled_cursor_name;
+    case GDK_X_CURSOR:
+    case GDK_ARROW:
+    case GDK_CENTER_PTR:
+    case GDK_DRAFT_LARGE:
+    case GDK_DRAFT_SMALL:
+    case GDK_LEFT_PTR:
+    case GDK_RIGHT_PTR:
+    case GDK_TOP_LEFT_ARROW:
+      return mir_arrow_cursor_name;
+    case GDK_CLOCK:
+    case GDK_WATCH:
+      return mir_busy_cursor_name;
+    case GDK_XTERM:
+      return mir_caret_cursor_name;
+    case GDK_HAND1:
+    case GDK_HAND2:
+      return mir_pointing_hand_cursor_name;
+      return mir_open_hand_cursor_name;
+    case GDK_FLEUR:
+      return mir_closed_hand_cursor_name;
+    case GDK_LEFT_SIDE:
+    case GDK_LEFT_TEE:
+    case GDK_RIGHT_SIDE:
+    case GDK_RIGHT_TEE:
+    case GDK_SB_LEFT_ARROW:
+    case GDK_SB_RIGHT_ARROW:
+      return mir_horizontal_resize_cursor_name;
+    case GDK_BASED_ARROW_DOWN:
+    case GDK_BASED_ARROW_UP:
+    case GDK_BOTTOM_SIDE:
+    case GDK_BOTTOM_TEE:
+    case GDK_DOUBLE_ARROW:
+    case GDK_SB_DOWN_ARROW:
+    case GDK_SB_UP_ARROW:
+    case GDK_TOP_SIDE:
+    case GDK_TOP_TEE:
+      return mir_vertical_resize_cursor_name;
+    case GDK_BOTTOM_LEFT_CORNER:
+    case GDK_LL_ANGLE:
+    case GDK_TOP_RIGHT_CORNER:
+    case GDK_UR_ANGLE:
+      return mir_diagonal_resize_bottom_to_top_cursor_name;
+    case GDK_BOTTOM_RIGHT_CORNER:
+    case GDK_LR_ANGLE:
+    case GDK_SIZING:
+    case GDK_TOP_LEFT_CORNER:
+    case GDK_UL_ANGLE:
+      return mir_diagonal_resize_top_to_bottom_cursor_name;
+      return mir_omnidirectional_resize_cursor_name;
+    case GDK_SB_V_DOUBLE_ARROW:
+      return mir_vsplit_resize_cursor_name;
+    case GDK_SB_H_DOUBLE_ARROW:
+      return mir_hsplit_resize_cursor_name;
+    default:
+      return mir_default_cursor_name;
+    }
+}
+
 static void
 gdk_mir_window_impl_set_device_cursor (GdkWindow *window,
                                        GdkDevice *device,
                                        GdkCursor *cursor)
 {
-  //g_printerr ("gdk_mir_window_impl_set_device_cursor window=%p\n", window);
-  /* We don't support cursors yet... */
+  const gchar *cursor_name;
+  MirCursorConfiguration *configuration;
+
+  if (cursor)
+    cursor_name = get_cursor_name_for_cursor_type (gdk_cursor_get_cursor_type (cursor));
+  else
+    cursor_name = mir_default_cursor_name;
+
+  configuration = mir_cursor_configuration_from_name (cursor_name);
+
+  if (configuration)
+    {
+      GdkMirWindowImpl *impl = GDK_MIR_WINDOW_IMPL (window->impl);
+
+      if (impl->surface)
+        mir_surface_configure_cursor (impl->surface, configuration);
+
+      mir_cursor_configuration_destroy (configuration);
+    }
 }
 
 static void